#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cmath>
#include <iomanip>
#include <cfloat>

using namespace std;

struct point
{
    int x;
    int y;
};

bool cmpx(point& p1, point& p2)
{
    return p1.x < p2.x;
}

bool cmpy(point& p1, point& p2)
{
    return p1.y < p2.y;
}

double distance(point& p1, point& p2)
{
    return sqrt(abs(p1.x - p2.x) * abs(p1.x - p2.x) + abs(p1.y - p2.y) * abs(p1.y - p2.y));
}

double closestpair(vector<point>& points, int left, int right)
{
    if (right - left <= 3)
    {
        double mindist = DBL_MAX;
        for (int i = left; i < right; ++i)
        {
            for (int j = i + 1; j < right; ++j)
            {
                mindist = min(mindist, distance(points[i], points[j]));
            }
        }
        return mindist;
    }
    int mid = (right + left) / 2;
    int midx = points[mid].x;
    double dl = closestpair(points, left, mid);
    double dr = closestpair(points, mid, right);
    double d = min(dl, dr);

    vector<point> strips;
    for (int i = left; i < right; ++i)
    {
        if (abs(points[i].x - midx) < d)
        {
            strips.push_back(points[i]);
        }
    }
    sort(strips.begin(), strips.end(), cmpy);
    for (int i = 0; i < strips.size(); ++i)
    {
        for (int j = i + 1; j < strips.size(); ++j)
        {
            if (abs(strips[i].y - strips[j].y) < d)
                d = min(d, distance(strips[i], strips[j]));
        }
    }
    return d;
}

int main()
{
    int n;
    int m;
    cin >> n;
    while (n--)
    {
        cin >> m;
        vector<point> points(m);
        for (int i = 0; i < m; ++i)
            cin >> points[i].x >> points[i].y;
        sort(points.begin(), points.end(), cmpx);
        double ret = closestpair(points, 0, points.size());
        cout << fixed << setprecision(4) << ret << endl;
    }
    return 0;
}